class Solution:
    def buddyStrings(self, A, B):
        """
        :type A: str
        :type B: str
        :rtype: bool
        """
        if not all([A,B]):
            return False
        A = list(A)
        B= list(B)
        unlike = []
        for i,c in enumerate(A):
            if B[i] != c:
                unlike.append([c,B[i]])
        if len(unlike) == 2:
            unlike[0].sort()
            unlike[1].sort()
            if unlike[0] == unlike[1]:
                return True
        elif A==B:
            if len(set(A))==len(set(B)) and len(set(A))!=len(A):
                return True
        return False

        
def main():
    sol = Solution()
    print(sol.buddyStrings("aa",'aa'))
    
if __name__=="__main__":
    main()